<div class="layui-fluid nepadmin-pad0 nepadmin-mar0 list0" id="list" lay-title="分红记录">
	<div class="layui-fluid">
		<div class="layui-row layui-col-space15">
			<div class="layui-col-md12">
				<div class="layui-card hxr-layui-card" id="memberlistv">
					<div class="layui-form hxradmin-card-header">
						<div class="layui-form-item">
							<div class="layui-inline">
								<label class="layui-form-label">关键词查询</label>
								<div class="layui-input-inline">
									<input type="text" name="user" autocomplete="off" class="layui-input" placeholder="会员姓名、设备编号">
								</div>
							</div>
							<div class="layui-inline">
								<label class="layui-form-label" style='width:85px;'>结束日期范围</label>
								<div class="layui-input-inline" style="width: 350px;">
									<input type="text" name="val2" id='date' autocomplete="off" class="layui-input" readonly>
								</div>
							</div>
							<div class="layui-inline">
								<button class="layui-btn" data-type="reload" id="search">搜索</button>
							</div>
							<div class="layui-inline">
								<button class="layui-btn" data-type="excel" id="pexcel">导出数据</button>
							</div>
						</div>
					</div>
					<div class="layui-card-body">
						<table class="layui-hide" id="list-table" lay-filter="list-table"></table>

					</div>
				</div>
				<script type="text/html" id="status">
				  {{#  if(d.status === 1){ }}
					<span class="layui-badge layui-bg-green">已支付</span>
				  {{#  } else if(d.status === 2) { }}
				    <span class="layui-badge">未支付</span>
				  {{#  } }}
				</script>
			</div>
		</div>
	</div>
</div>
<script>
	var formurl='member/memberform',formarea=['500px', '600px'];
	//表格数据渲染
	layui.use(['table', 'form','laydate'], function() {
		var table = layui.table,
			form = layui.form,
			$ = layui.$,laydate=layui.laydate;
			//日期范围
			  laydate.render({
			    elem: '#date'
				,type:'datetime'
			    ,range: true
			  });
			layui.admin.initlist(table,'members/bonus_list',240,[
				[{
					field: 'consume_record_id',
					title: 'ID',
					width: 60
				},{
					field: 'member_name',
					title: '会员姓名',
					width: 100
				},{
					field: 'old_money',
					title: '分红前余额(元)',
					width: 130
				},{
					field: 'change_money',
					title: '分红收益(元)',
					width: 110
				},{
					field: 'after_money',
					title: '分红后余额(元)',
					width: 130
				},{
					field: 'consume_name',
					title: '消费会员姓名',
					width: 120
				},{
					field: 'device_sn',
					title: '设备编号',
					minwidth: 150
				},{
					field: 'consume_desc',
					title: '消费信息',
					minwidth: 150
				},{
					field: 'start_time',
					title: '开始时间',
					width: 200
				},{
					field: 'end_time',
					title: '结束时间',
					width: 200
				},{
					field: 'count_time',
					title: '消费总时',
					width: 150
				},{
					field: 'consume_amount',
					title: '消费金额(元)',
					width: 150
				}]
			])
		//监听表格表单操作
		form.on('switch(list-tableF)', function(obj) {
			var json = JSON.parse(decodeURIComponent($(this).data('json')));
			json = table.clearCacheKey(json);
			// json.member_status == 1 ? json.member_status = 2 : json.member_status = 1;
			layui.admin.ajax('members/update_member', json).then((res) => {
				layui.admin.ahint(res.code,res.msg);
				layui.table.reload('list-table');
			}).catch((res) => {});
		});
		$('#search').on('click', function() {
			var val1 = $('input[name="user"]').val(),
			val2 = $('input[name="val2"]').val();
			layui.admin.reloads({
				search_text:val1,
				datemin:val2.split(' - ')[0],
				datemax:val2.split(' - ')[1]
			});
		});
		//导出
		$('#pexcel').on('click', function() {
			var val1 = $('input[name="user"]').val(),
					val2 = $('input[name="val2"]').val();
			layui.admin.excel(table,'members/bonus_list',
					{
						search_text:val1,
						datemin: val2.split(' - ')[0],
						datemax: val2.split(' - ')[1]
					},'');
		});
	});
</script>
